var str_crt_chapter; var str_crt_group; var str_crt_attribute; var n_crt_group; var n_crt_attribute; var n_crt_pos; var b_group_open; var max_height = 555; var metaModelDoc; var metaModelTxt=""; var crt_class_node; var str_dialog_name = ""; var error_message = ""; function activate(showDiv) { var n_chapter_count = document.getElementById("chapter_container").childNodes.length; for ( var i = 0; i < n_chapter_count; i++) { document.getElementById("chapter_container").childNodes[i].style.display = "none"; } document.getElementById(showDiv).style.display = "block"; setPageIndex(showDiv); } function pageBrowse(step) { var i = 0; while (document.getElementById("chapter_container").childNodes[i].style.display != "block") { i++;} document.getElementById("chapter_container").childNodes[i].style.display = "none"; i = i + step; if (i == -1) {i = document.getElementById("chapter_container").childNodes.length - 1;} else if (i > document.getElementById("chapter_container").childNodes.length - 1) { i = 0;} document.getElementById("chapter_container").childNodes[i].style.display = "block"; setPageIndex(document.getElementById("chapter_container").childNodes[i].id); } function setPageIndex(crtPageID) { var str_chapterID = crtPageID.substring(0,crtPageID.lastIndexOf("_")); var nodes = document.getElementById("chapter_container").childNodes; var n_max_ID = 1; var str_page_index = ""; for ( var i = 0; i < nodes.length; i++) { if (nodes[i].id.indexOf(str_chapterID) != -1) { if (i == nodes.length - 1) {n_max_ID = nodes[i].id[nodes[i].id.length - 1]; break; } else if (nodes[i+1].id.indexOf(str_chapterID) == -1){ n_max_ID = nodes[i].id[nodes[i].id.length - 1]; break; } } } if (n_max_ID > 1) { str_page_index = crtPageID.substring(crtPageID.lastIndexOf("_") + 1, crtPageID.length) + " / " + n_max_ID; } document.getElementById("browse_span").textContent = str_page_index; //set tab offset var n_tab_index = crtPageID.substring(crtPageID.indexOf("_") + 1, crtPageID.lastIndexOf("_")); nodes = document.getElementById("tab_container").childNodes; for ( var i = 0; i < n_tab_index - 1; i++) nodes[i].style.marginLeft = "13px"; for ( var i = n_tab_index - 1; i < nodes.length; i++) { var offset = Math.min (13, 2*(i - (n_tab_index - 1))); nodes[i].style.marginLeft = offset + "px"; } } function clear_chapters() { var el_tab_container = document.getElementById("tab_container"); var el_chapter_container = document.getElementById("chapter_container"); while (el_tab_container.childNodes.length>0) { el_tab_container.removeChild(el_tab_container.firstChild); } while (el_chapter_container.childNodes.length>0){el_chapter_container.removeChild(el_chapter_container.firstChild);} } function checkTabSize(Level) { var el_tab_container = document.getElementById("tab_container"); for ( var i = 0; i < el_tab_container.childNodes.length; i++) { var crt_tab = el_tab_container.childNodes.item(i); crt_tab.className = "tab"; crt_tab.className += (" tab_" + Level); var tab_lines = crt_tab.firstChild.offsetHeight/13; if (tab_lines > 1) if (Level < 4) { checkTabSize(Level+1); document.getElementById("tab_container").setAttribute("style", "width:" + (crt_tab.offsetWidth + 14) + "; "); /*!!!!!!!!!!!!!!!!!!!!!*/ return; } } } function truncateTabNames() { var el_tab_container = document.getElementById("tab_container"); for ( var i = 0; i < el_tab_container.childNodes.length; i++) { var crt_tab = el_tab_container.childNodes.item(i); crt_tab.className = "tab"; var tab_lines = crt_tab.firstChild.offsetHeight/13; if (tab_lines > 1) { crt_tab.firstChild.firstChild.textContent += "..."; while (crt_tab.firstChild.offsetHeight > 13) { var temp_str = crt_tab.firstChild.firstChild.textContent; crt_tab.firstChild.firstChild.textContent = temp_str.substring(0, temp_str.length-4) + "..."; } } } } function parseAttrRep() { str_crt_chapter = ""; str_crt_group = ""; str_crt_attribute = ""; n_crt_group = 0; n_crt_attribute = 0; n_crt_pos = 0; b_group_open = 0; max_height = 555; error_message = ""; clear_chapters(); var str_rows = document.getElementById("attrrep_txt").value.toString().split("\n"); var b_first_chapter = 1; var str_row = ""; if (crt_class_node == null) readCrtClassNode(); else if (crt_class_node.attributes.getNamedItem("name").nodeValue != document.getElementById("dropdown_class").value) readCrtClassNode(); for ( var i = 0; i < str_rows.length; i++) { var n_pos = 0; var n_pos_min = 0; var str_toktype = ""; str_row = str_rows[i]; while ((n_pos_min != -1) && (str_toktype != "#")) { n_pos_min = -1; str_toktype = "#"; var n_pos_raute = str_row.indexOf("#", n_pos); if (n_pos_raute != -1) { n_pos_min = n_pos_raute; str_toktype = "#"; } var n_pos_ch = str_row.indexOf("CHAPTER", n_pos); if (n_pos_ch != -1) { if ((n_pos_min > n_pos_ch) || (n_pos_min == -1)) { n_pos_min = n_pos_ch; str_toktype = "CHAPTER"; } } var n_pos_group = str_row.indexOf("GROUP", n_pos); if (n_pos_group != -1) { if ((n_pos_min > n_pos_group) || (n_pos_min == -1)) { n_pos_min = n_pos_group; str_toktype = "GROUP"; } } var n_pos_endgroup = str_row.indexOf("ENDGROUP", n_pos); if (n_pos_endgroup != -1) { if ((n_pos_min > n_pos_endgroup) || (n_pos_min == -1)) { n_pos_min = n_pos_endgroup; str_toktype = "ENDGROUP"; } } var n_pos_attr = str_row.indexOf("ATTR", n_pos); if (n_pos_attr != -1) { if ((n_pos_min > n_pos_attr) || (n_pos_min == -1)) { n_pos_min = n_pos_attr; str_toktype = "ATTR"; } } if ((n_pos_min != -1) && (str_toktype != "#")) { n_pos = n_pos_min; if (str_toktype == "ENDGROUP") { n_pos = n_pos + 8; if (b_group_open == 1) end_group(); //# a group can be closed only if alrady open; start event for token "ENDGROUP" } else { //# get token name var n_origpos = n_pos; n_pos = str_row.indexOf("\"", n_pos+1); var n_pos_tmp = n_pos; var n_pos_end = -1; var str_charbefore = "\\"; var str_name = ""; var str_fullname = ""; if (n_pos != -1) { //# there is a name so search the end of the name but ignore masked quotas while (str_charbefore == "\\") { n_pos_end = str_row.indexOf("\"", n_pos_tmp + 1); str_charbefore = str_row.charAt(n_pos_end - 1); if (str_charbefore == "\\") { str_name = str_name + str_row.substring(n_pos_tmp + 1, n_pos_end - 1) + "\""; n_pos_tmp = n_pos_end; } } } if ((n_pos != -1) && (n_pos_end != -1)) { str_fullname = str_name + str_row.substring( n_pos_tmp + 1, n_pos_end); n_pos = n_pos_end + 2; } else if (n_pos == -1) { n_pos = n_origpos + 1; } //start event for token "CHAPTER" if (str_toktype == "CHAPTER") { if (b_group_open == 1) end_group(); //start event for token "ENDGROUP" here, because the next chapter begins and the last group is still open if (b_first_chapter) b_first_chapter = 0; // after the first chapter else end_chapter(); //for the next chapters close the previous chapter start_chapter(str_fullname, str_row); } //start event for token "GROUP" if (str_toktype == "GROUP") { if (b_group_open) end_group(); // start event for token "ENDGROUP" here, because the next group begins and the last group is still open start_group(str_fullname, str_row); } // start event for token "ATTR" if (str_toktype == "ATTR") { if (str_fullname == ""){/*add error to log*/} else start_attribute(str_fullname, str_row); break; } } } } }//the for loop ends here end_chapter(); //close the last chapter for ( var i = 0; i < document.getElementById("chapter_container").childNodes.length; i++) document.getElementById("chapter_container").childNodes[i].setAttribute("style","display:none;"); activate("chapter_1_1"); // checkTabSize(0); truncateTabNames(); if (error_message != "") alert(error_message); } //parser ends here function readAttrRep() { /*read the existing AttrRep from the xml metamodel*/ readCrtClassNode(); var attrRepNode = getNodeByTagAndName(getNodeByTag(crt_class_node, "attributes") , "classattribute", "AttrRep"); var valueNode = getNodeByTag(attrRepNode, "value"); var leoNode = getNodeByTag(valueNode, "leo"); document.getElementById("attrrep_txt").value = ""; if(leoNode != null) { for ( var i = 0; i < leoNode.childNodes.length; i++) { var crtLine = leoNode.childNodes.item(i); var str_to_write = ""; str_to_write += crtLine.nodeName.toUpperCase(); if (str_to_write != "#TEXT") { if (crtLine.getAttribute("val") != null) str_to_write += " \"" + crtLine.getAttribute("val") + "\""; for ( var j = 1; j < crtLine.attributes.length; j++) { var crtAttrib = crtLine.attributes.item(j).name; if (crtAttrib.indexOf("opt-") == -1) { str_to_write += " " + crtAttrib.substring(crtAttrib.indexOf("-")+1, crtAttrib.length) + ":"; str_to_write += crtLine.attributes.item(j).value; /*very important to check the keywords and quotation marks...; quotation marks only for (un)checked...*/ } } document.getElementById("attrrep_txt").value += str_to_write + "\n"; //write str_to_write } } } } function start_chapter(chapterName, currentRow) { var str_tab_index = (document.getElementById("tab_container").childNodes.length + 1).toString(); var tab_style = ""; //create new tab, set tab attributes, add tab to tab_container var new_tab = document.createElement("div"); new_tab.setAttribute("class", "tab"); new_tab.setAttribute("id","tab_" + str_tab_index); new_tab.setAttribute("onClick", "javascript:activate('chapter_" + str_tab_index + "_1');" ); var new_tab_link = document.createElement("a"); new_tab_link.setAttribute("name", "tab_" + str_tab_index + "_link"); new_tab_link.setAttribute("href", "javascript:activate('chapter_" + str_tab_index + "_1');"); var color = getProperty(currentRow, "color:"); if (color.length > 0) tab_style = tab_style + "color:" + color + "; "; try { new_tab_link.setAttribute("style", tab_style); } catch (e) {} new_tab_link.appendChild(document.createTextNode(chapterName)); new_tab.appendChild(new_tab_link); //create new chapter, set chapter attributes, add new chapter to chapter_container var new_chapter = document.createElement("div"); new_chapter.setAttribute("class", "chapter"); new_chapter.setAttribute("id","chapter_" + str_tab_index); new_chapter.setAttribute("style", "display:block;"); //display the first chapter when initializing and hide all others document.getElementById("tab_container").appendChild(new_tab); document.getElementById("chapter_container").appendChild(new_chapter); str_crt_chapter = "chapter_" + str_tab_index; //set current chapter str_crt_group = ""; n_crt_group = 0; b_group_open = 0; //set current group as null; no group is open n_crt_attribute = 0; //set crt_attribute = 0 } function end_chapter() /*close chapter and split it into pages*/ { if (b_group_open == 1) end_group(); var crt_chapter = document.getElementById(str_crt_chapter); var crt_height = 0; var crt_page = 1; var actual_chapter = document.createElement("div"); actual_chapter.setAttribute("class", "chapter"); actual_chapter.setAttribute("id",str_crt_chapter + "_" + crt_page); actual_chapter.setAttribute("style", "display:block;"); document.getElementById("chapter_container").appendChild(actual_chapter); var new_height = 0; if (crt_chapter != null) { while (crt_chapter.childNodes.length > 0) { new_height = crt_height + crt_chapter.firstChild.offsetHeight; if (new_height <= max_height) { crt_height = new_height; actual_chapter.appendChild(crt_chapter.firstChild); } else { crt_height = crt_chapter.firstChild.offsetHeight; crt_page = crt_page + 1; actual_chapter = document.createElement("div"); actual_chapter.setAttribute("class", "chapter"); actual_chapter.setAttribute("id",str_crt_chapter + "_" + crt_page); actual_chapter.setAttribute("style", "display:block;"); document.getElementById("chapter_container").appendChild(actual_chapter); actual_chapter.appendChild(crt_chapter.firstChild); new_height = 0; } } document.getElementById(str_crt_chapter).parentNode.removeChild(crt_chapter); } } function start_group(groupName, currentRow) { n_crt_group++ ; str_crt_group = str_crt_chapter + "_group_" + n_crt_group.toString(); b_group_open = 1; var new_group = document.createElement("div"); new_group.setAttribute("class", "group"); new_group.setAttribute("id", str_crt_group); new_group.appendChild(buildSpanElement(groupName, "color:" + getProperty(currentRow, "color:") + "; ")); document.getElementById(str_crt_chapter).appendChild(new_group); n_crt_pos = n_crt_pos + 1; } function end_group() { str_crt_group = ""; b_group_open = 0; } //set crt_group=null function start_attribute(attributeName, currentRow) { n_crt_attribute = n_crt_attribute + 1; str_dialog_name = ""; var icons = new Array(); var crt_attr_type = "1"; var str_ctrltype = ""; var n_ctrl_id = 1; var n_standard_control_type = 1; //1=standard control type; 0=control types with border (like a group); 2=checkbox or radio buttons var attrib_style = ""; var line_tokens = currentRow.split(" "); for ( var i = 0; i < line_tokens.length; i++) { var str_keyword = line_tokens[i]; if (str_keyword.indexOf("ctrltype") > -1) str_ctrltype = str_keyword.substring(str_keyword.indexOf(":") + 1, str_keyword.length); } // read attribute type for current node and attribute from the metamodel (XML file) var attributeNode = getAttributeNode(crt_class_node, attributeName); if (attributeNode == null) crt_attr_type = "integer"; //safety net!!!!!!! else crt_attr_type = attributeNode.attributes.getNamedItem("type").nodeValue; //find the formatting keywords for the current attribute var idx_writeprotect = currentRow.indexOf("write-protected"); var idx_noparam = currentRow.indexOf("no-param"); var idx_pushbutton = currentRow.indexOf("push-button"); var idx_formulav = currentRow.indexOf("formula-visible"); var idx_noauto = currentRow.indexOf("no-auto"); var idx_notitle = currentRow.indexOf("notitle"); var idx_fontfamily = currentRow.indexOf("font-family"); var idx_lines = currentRow.indexOf("lines"); var idx_dialog = currentRow.indexOf("dialog"); var n_lines = 1; //getControlParameters(currentRow, crt_attr_type, n_ctrl_id, n_lines, icons); set the corresponding control id and button ids for the current attribute type switch (crt_attr_type) { case "string": case "longstring": var b_isMultiline = getNodeByTag(getNodeByTagAndName(getNodeByTag(attributeNode, "facets"), "facet", "MultiLineString"), "value").textContent; if (b_isMultiline == "1") {n_lines = 5; if (idx_lines > -1) {n_lines = getProperty(currentRow, "lines:");} n_ctrl_id = 2; icons = new Array("1");} break; case "time": case "date": case "datetime": icons = new Array("1"); break; case "enum": if (str_ctrltype == "check" ) { n_ctrl_id = 3; } else if (str_ctrltype == "check") { n_ctrl_id = 5;n_standard_control_type = 2;} else {n_ctrl_id = 4; n_standard_control_type = 2; } break; case "enumlist": n_ctrl_id = 2; icons = new Array("2", "3"); n_lines = 3; if (idx_lines > -1) n_lines = getProperty(currentRow, "lines:"); break; case "programcall": n_ctrl_id = 7; n_standard_control_type = 0; /*n_ctrl_id += 1*(idx_pushbutton > -1) + 2*(idx_noparam > -1);*/ if (idx_pushbutton > -1) {n_ctrl_id = n_ctrl_id + 1;} if (idx_noparam > -1) {n_ctrl_id = n_ctrl_id + 2;} /*apply the options push-button and no-param */ break; case "record": n_ctrl_id = 6; icons = new Array("2", "3", "1"); break; case "expression": if (idx_formulav>-1) { icons = new Array("5");} if (idx_lines > -1) {n_lines = getProperty(currentRow, "lines:"); n_ctrl_id = 2;} if (idx_dialog > -1) {str_dialog_name = getProperty(currentRow, "dialog:"); icons = icons.concat(new Array("1"));} break; case "interref": icons = new Array("2", "3", "4"); n_lines = 1; if (idx_lines > -1) n_lines = getProperty(currentRow, "lines:"); else { var facetValueNode = getNodeByTag(getNodeByTagAndName(getNodeByTag(attributeNode, "facets"), "facet", "AttributeInterRefDomain"), "value"); var n_noOfLines = getNodeByTag(getNodeByTag(facetValueNode, "leo"), "refdomain").attributes.getNamedItem("val-max").nodeValue; n_lines = Math.min(5, n_noOfLines); } if (n_lines >1) n_ctrl_id = 2; break; case "attrprofref": n_ctrl_id = 11; n_standard_control_type = 0; break; default: break; } attrib_style = setStyleText(idx_writeprotect, idx_fontfamily, currentRow); if (attributeNode != null) { var str_attrHelpText = getNodeByTag(getNodeByTagAndName(getNodeByTag( attributeNode, "facets"), "facet", "AttributeHelpText"), "value").textContent; if (str_attrHelpText.length > 0) icons = icons.concat(new Array("6")); } new_attribute = document.createElement("div"); new_attribute.setAttribute("id", str_crt_chapter + "_attribute_" + n_crt_attribute.toString()); if (n_standard_control_type == 1) { new_attribute.setAttribute("class", "attribute"); new_attribute.appendChild(buildIconsElement(icons,crt_attr_type, currentRow)); new_attribute.appendChild(buildNameElement(attributeName + ":", attrib_style)); new_attribute.appendChild(buildControlElement(n_ctrl_id, n_lines, attributeNode)); } else if (n_standard_control_type == 2) { new_attribute.setAttribute("class", "group"); if (n_ctrl_id == 5) new_attribute.style.border = "none"; if (n_ctrl_id == 4) { new_attribute.appendChild(buildSpanElement(attributeName, attrib_style)); var str_enumDomain = getNodeByTag(getNodeByTagAndName(getNodeByTag(attributeNode, "facets"), "facet", "EnumerationDomain"), "value").textContent; var options_list = str_enumDomain.split("@"); for ( var i = 0; i < options_list.length; i++) { new_attribute.appendChild(buildImgElement(n_ctrl_id, "middle")); new_attribute.appendChild(document.createTextNode(" " + options_list[i])); new_attribute.appendChild(document.createElement("br")); } } else /* n_ctrl_id == 3 or 5*/ { new_attribute.appendChild(buildImgElement(n_ctrl_id, "middle")); new_attribute.appendChild(document.createTextNode(" " + attributeName)); } } else if (n_standard_control_type == 0) { new_attribute.setAttribute("class", "group"); new_attribute.appendChild(buildSpanElement(attributeName, attrib_style)); new_attribute.appendChild(buildImgElement(n_ctrl_id, "", n_lines)); } //add attribute to group or chapter if (str_crt_group == "") { document.getElementById(str_crt_chapter).appendChild(new_attribute); } else { document.getElementById(str_crt_group).appendChild(new_attribute); } } function buildIconsElement(Icons, CrtAttrType, CrtRow) { var new_attr_icons = document.createElement("div"); new_attr_icons.setAttribute("class", "icons"); //create nodes for icons for ( var i = 0; i < Icons.length; i++) { var new_attr_icon_link = document.createElement("a"); var str_linked_image = getIconDialog(Icons[i], CrtAttrType, CrtRow); var new_attr_icon = document.createElement("img"); new_attr_icon.setAttribute("src", "images/b_" + Icons[i] + ".jpg"); new_attr_icon.setAttribute("class", "icon_img"); new_attr_icons.appendChild(document.createTextNode(" ")); if (str_linked_image.length == 0){ new_attr_icons.appendChild(new_attr_icon); } else { new_attr_icon_link.setAttribute("href", getIconDialog(Icons[i], CrtAttrType, CrtRow)); new_attr_icon_link.setAttribute("rel", "lightbox"); new_attr_icon_link.appendChild(new_attr_icon); new_attr_icons.appendChild(new_attr_icon_link); } } return new_attr_icons; } function buildNameElement(Name, Style) { var new_attr_name = document.createElement("div"); try { new_attr_name.setAttribute("style", Style); } catch (e) {} new_attr_name.appendChild(document.createTextNode(" " + Name)); return new_attr_name; } function buildControlElement(CtrlID, Lines, AttributeNode) { var new_attr_control = document.createElement("div"); new_attr_control.setAttribute("class", "control"); new_attr_control.appendChild(buildImgElement(CtrlID, "", Lines, AttributeNode)); return new_attr_control; } function buildImgElement(CtrlID, AlignStyle, Lines, AttributeNode) { var new_attr_ctrl_picture; if(CtrlID == 6) { new_attr_ctrl_picture = document.createElement("table"); new_attr_ctrl_picture.setAttribute("class", "record_table"); new_attr_ctrl_picture.setAttribute("cellspacing", "0"); var row; var cell; row = document.createElement("tr"); cell = document.createElement("th"); cell.setAttribute("class", "first_header"); row.appendChild(cell); var facetNode = getNodeByTagAndName(getNodeByTag(AttributeNode, "facets"), "facet", "RecordClassName"); var recordClassName = getNodeByTag(facetNode, "value").textContent; var recordClassNode = getNodeByTagAndName(getNodeByTag(getNodeByTag(metaModelDoc, "library"),"classes"),"recordclass", recordClassName); var recordClassAttributesNode = getNodeByTag(recordClassNode, "attributes"); var n_columns = 0; for ( var i = 0; i < recordClassAttributesNode.childNodes.length; i++) { if (recordClassAttributesNode.childNodes.item(i).nodeName == "attribute") { n_columns++; cell = document.createElement("th"); cell.appendChild(document.createTextNode(recordClassAttributesNode.childNodes.item(i).getAttribute("name"))); cell.setAttribute("class", "headers"); row.appendChild(cell); } } new_attr_ctrl_picture.appendChild(row); for ( var j = 0; j < 5; j++) { row = document.createElement("tr"); cell = document.createElement("th"); cell.setAttribute("class", "first_cell"); row.appendChild(cell); for ( var i = 0; i < n_columns; i++) { cell = document.createElement("td"); cell.appendChild(document.createTextNode("cell " + j + "_" + i)); row.appendChild(cell); } new_attr_ctrl_picture.appendChild(row); } } // else if(CtrlID == 11) // { // var facetNode = getNodeByTagAndName(getNodeByTag(AttributeNode, "facets"), "facet", "AttributeProfileRefDomain"); // var attrProfClassName = getNodeByTag(facetNode, "value").textContent; // var attrProfClassNode = getNodeByTagAndName(getNodeByTag(getNodeByTag(metaModelDoc, "library"),"classes"),"attrprofclass", attrProfClassName); // var attrProfClassAttributesNode = getNodeByTag(attrProfClassNode, "attributes"); // // new_attr_ctrl_picture = document.createElement("div"); // new_attr_ctrl_picture.setAttribute("class", "group"); // // new_group.appendChild(buildSpanElement(groupName, "color:" + getProperty(currentRow, "color:") + "; ")); // document.getElementById(str_crt_chapter).appendChild(new_group); // n_crt_pos = n_crt_pos + 1; // // for ( var i = 0; i < attrProfClassAttributesNode.childNodes.length; i++) // { /*to modify*/ // if (attrProfClassAttributesNode.childNodes.item(i).nodeName == "attribute") // { // cell = document.createElement("th"); // cell.appendChild(document.createTextNode(recordClassAttributesNode.childNodes.item(i).getAttribute("name"))); // cell.setAttribute("class", "headers"); // row.appendChild(cell); // } // } // } else { new_attr_ctrl_picture = document.createElement("img"); new_attr_ctrl_picture.setAttribute("src", "images/c_" + CtrlID + ".jpg"); new_attr_ctrl_picture.setAttribute("class", "control_img"); new_attr_ctrl_picture.style.verticalAlign = AlignStyle; if (CtrlID == 2) { new_attr_ctrl_picture.setAttribute("height", (4.5 + 16.5 * Lines) + "px"); new_attr_ctrl_picture.setAttribute("width", "100%"); } } return new_attr_ctrl_picture; } function buildSpanElement(Name, Style) { var new_span = document.createElement("span"); new_span.setAttribute("class", "group_label"); try {new_span.setAttribute("style", Style);} catch (e) {} new_span.appendChild(document.createTextNode(Name)); return new_span; } function setStyleText(IdxWriteProtect, IdxFontFamily, CrtRow) { var attrib_style = ""; if (IdxWriteProtect > -1) { attrib_style = attrib_style + "color:grey; "; } else {attrib_style = attrib_style + "color:" + getProperty(CrtRow, "color:") + "; "; } if (IdxFontFamily > -1) {attrib_style = attrib_style + "font-family:" + getProperty(CrtRow, "font-family:") + "; "; } return attrib_style; } function getProperty(crtRow, propertyName) { var propertyVal = ""; var idx_property = crtRow.indexOf(propertyName); if (idx_property > -1) { var idx_space = (crtRow + " ").indexOf(" ",idx_property + propertyName.length + 1); propertyVal = crtRow.substring(idx_property + propertyName.length, idx_space); } return propertyVal; } function getIconDialog(iconID,attrType,crtRow) { var dialogValue = ""; var dlgPropertyValue = getProperty(crtRow, "dialog:"); switch (iconID) { case "5": dialogValue = "editexpression"; break; case "2": if (attrType == "enumlist") dialogValue = "enumerationlist"; else if (attrType == "attrprofref") dialogValue = "attribute_profile_selection"; else if (attrType == "interref") { if (dlgPropertyValue.length > 0) dialogValue = dlgPropertyValue; else dialogValue = "add_reference"; } break; case "1": if (str_dialog_name == "") { switch (attrType) { case "longstring": case "string": if (dlgPropertyValue.length > 0) dialogValue = dlgPropertyValue; else dialogValue = "string"; break; case "time": if (dlgPropertyValue.length > 0) dialogValue = dlgPropertyValue; else dialogValue = "time"; break; case "date": if (dlgPropertyValue.length > 0) dialogValue = dlgPropertyValue; else dialogValue = "date"; break; case "datetime": if (dlgPropertyValue.length > 0) dialogValue = dlgPropertyValue; else dialogValue = "datetime"; break; case "record": dialogValue = "table"; break; default: break; } } else dialogValue = str_dialog_name; break; default: dialogValue = ""; break; } if (dialogValue.length > 0) dialogValue = "images/dialog_" + dialogValue + ".png"; return dialogValue; } function readMetaModel(FileContents) { var parseXml; if (typeof window.ActiveXObject != "undefined" && new window.ActiveXObject("Microsoft.XMLDOM")) { parseXml = function(xmlStr) { var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(xmlStr); return xmlDoc; }; } else if (typeof window.DOMParser != "undefined") { parseXml = function(xmlStr) { var myParser = new window.DOMParser(); return myParser.parseFromString(xmlStr, "text/xml"); }; } var tempStr = ""; tempStr = FileContents; var newStr = tempStr.substring(tempStr.indexOf(" 0) { document.getElementById("dropdown_class").removeChild(document.getElementById("dropdown_class").firstChild);} var classes = getNodeByTag(libraryNode ,"classes").childNodes; for ( var i = 0; i < classes.length; i++) { var crtNode = classes.item(i); if (crtNode.nodeName == "class") { var valueNode = getNodeByTag(getNodeByTagAndName(getNodeByTag(classes.item(i), "attributes"), "classattribute", "ClassAbstract"), "value"); if (valueNode != null) if ( valueNode.firstChild.nodeValue == 0) addClassOption(classes.item(i).attributes.getNamedItem("name").nodeValue); } else if (crtNode.nodeName == "relationclass") addClassOption(classes.item(i).attributes.getNamedItem("name").nodeValue); } alert( "The metamodel has been loaded!" ); } } function addClassOption(ClassName) { var newOption = document.createElement("option"); newOption.text = ClassName; newOption.value = ClassName; document.getElementById("dropdown_class").appendChild(newOption); } function readCrtClassNode() { var classesNode = getNodeByTag(metaModelDoc.firstChild, "classes"); var selectedClassName = document.getElementById("dropdown_class").value; crt_class_node = getNodeByTagAndName(classesNode, "class", selectedClassName); if (crt_class_node == null) crt_class_node = getNodeByTagAndName(classesNode, "relationclass", selectedClassName); if (crt_class_node == null){/* show error message */} } function getNodeByTag(CrtNode, TagName) { var retVal = null; if (CrtNode != null) { var nodes = CrtNode.childNodes; for ( var i = 0; i < nodes.length; i++) { if (nodes.item(i).nodeName == TagName) { retVal = nodes.item(i); break; } } } return retVal; } function getNodeByTagAndName(CrtNode, Tag, Name) { var retVal = null; var nodes = CrtNode.childNodes; for ( var i = 0; i < nodes.length; i++) { if (nodes.item(i).nodeName == Tag) if (nodes.item(i).attributes.getNamedItem("name").nodeValue == Name) { retVal = nodes.item(i); break; } } return retVal; } function getAttributeNode(ClassNode, AttributeName) { var retVal = null; if (ClassNode != null) { if (ClassNode.attributes.getNamedItem("name").nodeValue != "RootClass") { var attributeNode = getNodeByTagAndName(getNodeByTag(crt_class_node, "attributes"), "attribute", AttributeName); if (attributeNode == null) { var supClassNode = null; var supClassName = ClassNode.attributes.getNamedItem("superclass").nodeValue; supClassNode = getNodeByTagAndName(getNodeByTag(metaModelDoc.firstChild, "classes"), ClassNode.nodeName, supClassName ); retVal = getAttributeNode(supClassNode, AttributeName); } retVal = attributeNode; } else { if (AttributeName != "Name") error_message += "Attribute \"" + AttributeName + "\" could not be found for the class you selected!!! \n"; } } return retVal; } function readSingleFile(evt) { //Retrieve the first (and only!) File from the FileList object var f = evt.target.files[0]; if (f) { var r = new FileReader(); r.onload = function(evt) { var contents = evt.target.result; // contents = purgeString(contents); readMetaModel(contents); }; r.readAsText(f); } else { alert("Failed to load file"); } } function purgeString(XMLString) { var i = 0; // while (i < XMLString.length) // { // var idx_leo = XMLString.indexOf("",i); // var idx_leo_end = XMLString.indexOf("",idx_leo); // if (idx_leo > 0) // { // var idx_notebook = XMLString.indexOf("", idx_leo); // if ((idx_notebook < idx_leo_end) && (idx_notebook > 0)) // i = idx_leo_end + 6; // else // { // XMLString.replace(XMLString.substring(idx_leo, idx_leo_end + 5) ,""); // } // } // else break; // } // var libNode = getNodeByTag(metaModelDoc, "library"); // var attrsNode = getNodeByTag(libNode, "attributes"); // libNode.removeChild(attrsNode); return XMLString; } function backupAttrRep() { } function saveAttrRep() { // if (crt_class_node == null) // alert("No Class selected!"); // else // { // var attrRepNode = getNodeByTagAndName(getNodeByTag(crt_class_node, "attributes") , "classattribute", "AttrRep"); // var valueNode = getNodeByTag(attrRepNode, "value"); // valueNode.removeChild(valueNode.firstChild); // valueNode.value = document.getElementById("attrrep_txt").value; // valueNode.textContent = document.getElementById("attrrep_txt").value; // valueNode.nodeValue = document.getElementById("attrrep_txt").value; // // var s = new XMLSerializer(); // var xmlString = s.serializeToString(metaModelDoc); // var i=0; // } } function store() { var libName = document.getElementById("text_lib").firstChild.textContent; var className = document.getElementById("text_class").firstChild.textContent; var key_name = libName + "__" + className; localStorage[key_name] = "blablabla!!!!!!!"; var i = 0; } function retrieve() { var libName = document.getElementById("text_lib").firstChild.textContent; var className = document.getElementById("text_class").firstChild.textContent; var key_name = libName + "__" + className; var i = 0; alert(localStorage[key_name]); }